﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PomeloEfCoreSample.Data.Core;
using System;
using System.Collections.Generic;
using System.Text;

namespace PomeloEfCoreSample.Data.Mapping
{
    public class RoleMap
       : IEntityTypeConfiguration<Role>
    {
        public void Configure(EntityTypeBuilder<Role> builder)
        {
            //Table.
            builder.ToTable("T_Role");
            //Key.
            builder.HasKey(t => t.Id);
            //Props.
            builder.Property(t => t.Id)
                .HasColumnName("Id")
                .IsRequired(true);
            builder.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(20)
                .IsRequired(true);
            //Relations.
        }
    }
}
